#include "SyntaxTreeNode.h"

SyntaxTreeNode::SyntaxTreeNode() {
	type = ERROR;
	value = 0;
	left = right = NULL;
}
SyntaxTreeNode::SyntaxTreeNode(TokenType t, int val) {
	type = t;
	value = val;
	id_name = "";
	left = right = NULL;
}
SyntaxTreeNode::SyntaxTreeNode(TokenType t, std::string val) {
	type = t;
	value = 0;
	id_name = val;
	left = right = NULL;
}
SyntaxTreeNode::~SyntaxTreeNode() {
	if (left != NULL) {
		delete left;
	}
	if (right != NULL) {
		delete right;
	}
}

/*===================================================================*/

void SyntaxTreeNode::setType(TokenType t) {
	type = t;
}

TokenType SyntaxTreeNode::getType() {
	return type;
}

void SyntaxTreeNode::setValue(int val) {
	value = val;
}

void SyntaxTreeNode::setIdName(std::string val) {
	id_name = val;
}

int SyntaxTreeNode::getValue() {
	return value;
}

std::string SyntaxTreeNode::getIdName() {
	return id_name;
}
void SyntaxTreeNode::addLeft(TokenType t, int val) {
	left = new SyntaxTreeNode(t, val);
}
void SyntaxTreeNode::addLeft(SyntaxTreeNode *n) {
	left = n;
}

void SyntaxTreeNode::addRight(TokenType t, int val) {
	right = new SyntaxTreeNode(t, val);
}
void SyntaxTreeNode::addRight(SyntaxTreeNode *n) {
	right = n;
}

SyntaxTreeNode* SyntaxTreeNode::getLeft() {
	return left;
}

SyntaxTreeNode* SyntaxTreeNode::getRight() {
	return right;
}
